home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / UPC12BS1.ZIP / UUCICO / PRTYNT.C < prev    next >
C/C++ Source or Header  |  1993-09-30  |  4KB  |  93 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       p r t y n t . c                                              */
  3. /*                                                                    */
  4. /*       Set task priority for NT tasks under UUPC/extended           */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1993 by Kendra Electronic                 */
  9. /*    Wonderworks.                                                    */
  10. /*                                                                    */
  11. /*    All rights reserved except those explicitly granted by the      */
  12. /*    UUPC/extended license agreement.                                */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                        System include files                        */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. #include <stdio.h>
  20. #include <windows.h>
  21.  
  22. /*--------------------------------------------------------------------*/
  23. /*                    UUPC/extended include files                     */
  24. /*--------------------------------------------------------------------*/
  25.  
  26. #include "lib.h"
  27. #include "pnterr.h"
  28. #include "commlib.h"
  29.  
  30. /*--------------------------------------------------------------------*/
  31. /*                          Local variables                           */
  32. /*--------------------------------------------------------------------*/
  33.  
  34. currentfile();
  35.  
  36. static boolean restore = FALSE;
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /*       s e t P r t y                                                */
  40. /*                                                                    */
  41. /*       Set priority to configuration defined value                  */
  42. /*--------------------------------------------------------------------*/
  43.  
  44. void setPrty( const KEWSHORT priorityIn, const KEWSHORT prioritydeltaIn )
  45. {
  46. /*--------------------------------------------------------------------*/
  47. /*                     Up our processing priority                     */
  48. /*--------------------------------------------------------------------*/
  49.    HANDLE hProcess;
  50.    BOOL rc;
  51.  
  52.    hProcess = GetCurrentProcess();
  53.    rc = SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS);
  54.  
  55.    if (!rc)
  56.    {
  57.       DWORD err = GetLastError();
  58.  
  59.       printNTerror("setprty", err);
  60.    }
  61.  
  62.    restore = TRUE;
  63. }
  64.  
  65. /*--------------------------------------------------------------------*/
  66. /*       r e s e t P r t y                                            */
  67. /*                                                                    */
  68. /*       Restore priority saved by SetPrty                            */
  69. /*--------------------------------------------------------------------*/
  70.  
  71. void resetPrty( void )
  72. {
  73.    HANDLE hProcess;
  74.    BOOL rc;
  75.  
  76.    if ( !restore )
  77.       return;
  78.  
  79. /*--------------------------------------------------------------------*/
  80. /*                           Lower priority                           */
  81. /*--------------------------------------------------------------------*/
  82.  
  83.    hProcess = GetCurrentProcess();
  84.    rc = SetPriorityClass(hProcess, NORMAL_PRIORITY_CLASS);
  85.  
  86.    if (!rc)
  87.    {
  88.       DWORD err = GetLastError();
  89.       printNTerror("resetPrty", err);
  90.    }
  91.  
  92. }
  93.